<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
<style>
#target {
    height: 200px;
    width: 220px;
    border: 5px solid blue;
}
</style>
</head>
<body onload="runTest()">
<p id="description"></p>
<div contenteditable=true id="target"></div>
<div><object id="source" data="resources/apple.gif" type="image/png" itemprop="somedata" arbitrary="green" draggable=true></object></div>
<div id="console"></div>

<script>
description('This test verifies dropping an image does nothing. To test manually, drag the image and drop it in the rect with a blue border.');
var jsTestIsAsync = true;
var target = document.getElementById('target');
var imageIsInserted = false;

function contentInserted() {
    shouldBe('target.getElementsByTagName("object").length', '1');
    shouldBe('target.getElementsByTagName("object")[0].attributes.length', '6');
    shouldBeEqualToString('target.getElementsByTagName("object")[0].id', 'source');
    shouldBeEqualToString('target.getElementsByTagName("object")[0].type', 'image/png');
    shouldBeTrue('target.getElementsByTagName("object")[0].draggable');
    shouldBeEqualToString('target.getElementsByTagName("object")[0].attributes["itemprop"].value', 'somedata');
    shouldBeEqualToString('target.getElementsByTagName("object")[0].attributes["arbitrary"].value', 'green');
    imageIsInserted = true;
}

function runTest() {
    target.addEventListener('DOMNodeInserted', contentInserted, false);

    document.getElementById('source').addEventListener('dragend', function() {
        shouldBeFalse('imageIsInserted');
        finishJSTest();
    });

    if (!window.testRunner)
        return;

    testRunner.waitUntilDone();

    e = document.getElementById("source");
    x = e.offsetLeft + e.offsetWidth / 2;
    y = e.offsetTop + e.offsetHeight / 2;

    eventSender.mouseMoveTo(x, y);
    eventSender.mouseDown();
    eventSender.leapForward(100);
    e = document.getElementById("target");
    x = e.offsetLeft + e.offsetWidth / 2;
    y = e.offsetTop + e.offsetHeight / 2;

    eventSender.mouseMoveTo(x, y);
    eventSender.mouseUp();
}
</script>
</body>
</html>
